package com.sylli.oeuf.server.game.logic.invocation;

import java.util.Collection;
import java.util.Hashtable;

import com.sylli.oeuf.server.game.logic.CastingTarget;
import com.sylli.oeuf.server.game.logic.Skill;
import com.sylli.oeuf.server.game.logic.skill.Exorcist_Bane;
import com.sylli.oeuf.server.game.logic.skill.Exorcist_MinorHeal;
import com.sylli.oeuf.server.game.logic.skill.Exorcist_WrathOfTheLiving;
import com.sylli.oeuf.server.game.logic.skill.Heal;
import com.sylli.oeuf.server.game.logic.skill.NormalAttack;
import com.sylli.oeuf.server.game.logic.skill.Vampire_BatsSwarm;
import com.sylli.oeuf.server.game.logic.skill.Vampire_Drain;
import com.sylli.oeuf.server.game.logic.skill.Vampire_HellBlue;
import com.sylli.oeuf.server.game.logic.skill.Vampire_SangueImbottire;
import com.sylli.oeuf.server.game.logic.skill.passive.Exorcist_DivineSpirit;
import com.sylli.oeuf.server.game.logic.skill.passive.Exorcist_UndeadMastery;

public class LogicObjectFactory {
	
	private static Hashtable<String, Skill> skills =  new Hashtable<String, Skill>();
	
	static {
		registerSkill(new NormalAttack());
		registerSkill(new Heal());
		
		registerSkill(new Vampire_Drain());
		registerSkill(new Vampire_SangueImbottire());
		registerSkill(new Vampire_BatsSwarm());
		registerSkill(new Vampire_HellBlue());
		
		registerSkill(new Exorcist_UndeadMastery());
		registerSkill(new Exorcist_Bane());
		registerSkill(new Exorcist_DivineSpirit());
		registerSkill(new Exorcist_WrathOfTheLiving());
		registerSkill(new Exorcist_MinorHeal());
	}
	
	public static Skill getSkillByName(String skillname) {
		return skills.get(skillname);
	}
	
	public static Collection<String> getSkillNames() {
		return skills.keySet();
	}
	
	public static void registerSkill(Skill skill) {
		skills.put(skill.getName(), skill);
	}
	
	public static Skill createSkillByName(String skillname) {
		return skills.get(skillname);
	}
	
	public static InvocationCondition createCondition( 
			String condition, String conditionValue) {
		InvocationCondition ic = null;
		if (condition.equals("my hp")) {
			String[] s = conditionValue.split(" ",2);
			boolean isCheckGT = !s[0].trim().equals("<");
			int value = Integer.parseInt(s[1]);
			ic = new WatchHPInvocationCondition(isCheckGT, value);
		} else if (condition.equals("my mp")) {
			String[] s = conditionValue.split(" ",2);
			boolean isCheckGT = !s[0].trim().equals("<");
			int value = Integer.parseInt(s[1]);
			ic = new WatchMPInvocationCondition(isCheckGT, value);
		}
		return ic;
	}
	
	public static CastingTarget getCastingTarget(String target) {
		if (target.equals("focusTarget")) {
			return CastingTarget.FocusTarget;
		} else {
			return CastingTarget.Self;
		}
	}
}
